function Loading(options){

    //使用严格模式
    "use strict"

    var DEFAULTS = function () {
        return {
            container: "body",
            image: "loading.gif",
            background: "#000",
            opacity: 0.5,
            hasBackdrop: true
        }
    };
    var that = this;
    var config = $.extend(DEFAULTS(), options);
    var $container = $(config.container);
    var $image = $('<img class="loading-image" src="' + config.image + '" />');
    var $backdrop = $('<div class="loading-backdrop"></div>').css({
        "background": config.background,
        "-ms-filter": "progid:DXImageTransform.Microsoft.Alpha(Opacity=" + (config.opacity * 100) + ")",
        "filter": "alpha(opacity=" + (config.opacity * 100) + ")",
        "opacity": config.opacity
    });

    if (config.hasBackdrop) $container.append($backdrop);
    $container.css("position", "relative");
    $container.append($image);

    function show() {
        disableScrolling();
        $backdrop.show();
        $image.show();
    }

    function hide() {
        enableScrolling();
        $image.hide();
        $backdrop.hide();
    }

    function destroy() {
        config = undefined;
        $container.remove();
        $image.remove();
        $backdrop.remove();
        that = undefined;
    }

    function disableScrolling(container) {
        $(container || document.body).css({
            "padding-right": getScrollbarWidth(),
            "box-sizing": "border-box",
            "overflow": "hidden"
        });
    }

    function enableScrolling(container) {
        $(container || document.body).css({
            "padding-right": 0,
            "box-sizing": "",
            "overflow": ""
        });
    }
    
    function getScrollbarWidth() { // thx walsh
        var $body = $(document.body);
        var scrollDiv = document.createElement('div')
        scrollDiv.className = 'modal-scrollbar-measure'
        $body.append(scrollDiv);
        var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth
        $body[0].removeChild(scrollDiv);
        return scrollbarWidth
    }

    this.show = show;
    this.hide = hide;
    this.destroy = destroy;

}